<template>
  <div>
    <Image v-if="isImage" :src="cValue" :width="width" :height="height" />
    <Icon v-if="!isImage && cValue" :icon="cValue" />
  </div>
</template>
<script setup lang="ts">
  import { computed } from 'vue';
  import { Image } from 'ant-design-vue';
  import { Icon } from '@/components/Icon';

  const props = defineProps({
    code: {
      type: String,
    },
    data: {
      type: Object,
      default() {
        return {};
      },
    },
    value: {
      // 值
      type: [String],
    },
    width: {
      type: [String, Number],
      default: '48px',
    },
    height: {
      type: [String, Number],
      default: '48px',
    },
  });
  const cValue = computed(() => {
    return props.value;
  });
  const isImage = computed(() => {
    return cValue.value?.startsWith('http');
  });
</script>
<style lang="less" scoped></style>
